const getStr = (name) => {
    const str = localStorage.getItem(name)
    return str
}
const getObj = (name) => {
    const str = localStorage.getItem(name)
    if(str == null || str == undefined){
        return {}
    }
    const obj = JSON.parse(str)
    return obj
}
const setStr = (name, value) => {
    localStorage.setItem(name, value)
}
const setObj = (name, value) => {
    const obj = JSON.stringify(value)
    localStorage.setItem(name, obj)
}
const del = (name) => {
    localStorage.removeItem(name)
}
const loginSattus = () => {
    const obj = getObj('appuser')
    if(!obj) {
        return false
    }
    const b = checkToken(obj)
    return b
}
const checkToken = (token) => {
    if (token) {
        return true
    } else {
        return false
    }
}
const getToken=()=> {
    const token = getStr('token')
    return token
}
const utils = {
    getStr,
    getObj,
    setStr,
    setObj,
    del,
    loginSattus,
    getToken
}
export default utils